import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Test {


    public static void main(String[] args) {
        User user1 = new User();
        user1.setGender("男");
        user1.setName("张三");
        User user2 = new User();
        user2.setGender("女");
        user2.setName("里斯");

        List<User> userList = new ArrayList<>();
        userList.add(user2);
        userList.add(user1);


        // 方法1
        List<User> list1 = new ArrayList<>();
        for (User user : userList) {
            if(user.getGender().equals("男")) {
                list1.add(user);
            }
        }

        for (User user : userList){
            System.out.println(user.getName());
            System.out.println(user.getGender());
        }


        // 方法2 java8 stream
        List<User> list2 = userList.stream().filter(x -> x.getGender().equals("男")).collect(Collectors.toList());



        // maven , 本地仓库，远程仓库，
    }

}

class User {
    String name;
    String gender;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

}
